home *** CD-ROM | disk | FTP | other *** search
- Path: news.uni-jena.de!news
- From: mkt@isun04.inf.uni-jena.de (Tilo Koerbs)
- Newsgroups: comp.lang.c++
- Subject: Re: Aborting Constructors, Part II
- Date: 1 Feb 1996 11:48:13 GMT
- Organization: Lehrstuhl fuer Rechnerarchitektur- und kommunikation, FSU Jena
- Message-ID: <4eq99t$fpu@fsuj01.rz.uni-jena.de>
- References: <4eoeck$t6n@news.ios.com>
- Reply-To: mkt@isun04.inf.uni-jena.de
- NNTP-Posting-Host: isun07.inf.uni-jena.de
-
- > test::test(){
- > cout << "constructing object\n";
- > delete this;
- > throw(xmsg(string("deleted the object!\n")));
- > }
-
- I am sure that using delete on this is not allowed in C++.
- I can remember that Borland is a little bit strange in those things.
- They allow a 'return 0' in constructors if the object cannot be constructed
- and something else.
-
- While running a member function one cannot delete the object the function
- is working on. After the delete the object the function works with is
- not valid any more. So what is the function working with?
-
- The output is absolutely correct (if the program not crashes, which is a valid
- behaviour in such cases).
-
- But why can't you abort the constructor without this delete?
- Before throwing the exception you can free all dynamically (inside the
- constructor) created things.
- Bye.
-
-
-